package net.noday.demo.service;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import net.noday.demo.domain.Person;
import net.noday.demo.persistent.PersonDAO;

@Service
@Transactional
public class PersonService implements IPersonService {

	@Resource
	private PersonDAO personDAO;
	
	@Override
	public void save(Person person) {
		personDAO.add(person);
	}
	
	@Override
	public void update(Person person) {
		personDAO.update(person);
	}
	
	@Override
	@Transactional(propagation=Propagation.NOT_SUPPORTED)//��ʹ������
	public Person getPerson(Integer id) {
		return personDAO.get(id);
	}
	
	@Override
	public List<Person> getPersons() {
		return personDAO.getAll();
	}
	
	@Override
	@Transactional(rollbackFor=RuntimeException.class)
	public void delete(Integer id) {
		personDAO.delete(id);
		throw new RuntimeException("dd");
	}
	
}
